setwd("D:/1大学生活/大三下/zxy/R语言")
count <- read.table("D:/1大学生活/大三下/zxy/R语言/class2/count.csv", header = TRUE, stringsAsFactors = FALSE)
# 提取第一行（第一个基因）的所有样本的计数值
first_gene_counts <- as.numeric(count[1, -1])

# 绘制直方图
hist(first_gene_counts,
     breaks = 20,  # 分隔区间数
     main = paste("Histogram for Gene:", count[1, 1]), # 用第一列作为基因名标题
     xlab = "Counts across Samples",
     ylab = "Frequency",
     col = "lightblue") # 设置颜色

target_sample_col <- "PTB011D"

# 提取该样本的所有基因计数值
sample_expression <- count[[target_sample_col]]

# 绘制 log10(计数值 + 0.1) 的直方图 (加0.1避免log(0))
hist(log10(sample_expression + 0.1),
     breaks = 20,
     main = paste("Histogram of log10(Counts + 0.1) for", target_sample_col),
     xlab = "log10(Counts + 0.1)",
     ylab = "Frequency",
     col = "salmon")
  
